package com.tsystems.school.jabber.DataBase.Entities;


import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import javax.persistence.*;
import java.util.Collection;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Kirill
 * Date: 22.08.11
 * Time: 13:45
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table( name = "User" )
public class User  extends ManagedEntity{

	@Column(name="login")
	private String login;

	@Column(name="pass")
	private String password;

	@Column(name="info")
	private String info;

	@ManyToOne
	@Cascade({CascadeType.MERGE})
    @JoinColumn(name = "server_id")
	private Server server;

	@Column(name="address")
	private String address;


	@ManyToMany//(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	@JoinTable(name = "confuser",
    joinColumns = @JoinColumn(name = "member_id"),
    inverseJoinColumns = @JoinColumn(name = "conference_id"))
	private List<Conference> contacts;

	@OneToMany(mappedBy = "receiver")
	private Collection<PersonalMessage> personalMessages;

	public User() {
	}

	public List<Conference> getContacts() {
		return contacts;
	}

	public void setContacts(List<Conference> contacts) {
		this.contacts = contacts;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getInfo() {
		return info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public Server getServer() {
		return server;
	}

	public void setServer(Server server) {
		this.server = server;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}


	public Collection<PersonalMessage> getPersonalMessages() {
		return personalMessages;
	}

	public void setPersonalMessages(Collection<PersonalMessage> personalMessages) {
		this.personalMessages = personalMessages;
	}
}
